/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package slcu.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import slcu.service.CoordinadorLocalServiceUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.HashMap;
import java.util.Map;

/**
 * @author tito
 */
public class CoordinadorClp extends BaseModelImpl<Coordinador>
	implements Coordinador {
	public CoordinadorClp() {
	}

	public Class<?> getModelClass() {
		return Coordinador.class;
	}

	public String getModelClassName() {
		return Coordinador.class.getName();
	}

	public long getPrimaryKey() {
		return _coordinadorId;
	}

	public void setPrimaryKey(long primaryKey) {
		setCoordinadorId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_coordinadorId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("coordinadorId", getCoordinadorId());
		attributes.put("nombre", getNombre());
		attributes.put("region", getRegion());
		attributes.put("mail", getMail());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long coordinadorId = (Long)attributes.get("coordinadorId");

		if (coordinadorId != null) {
			setCoordinadorId(coordinadorId);
		}

		String nombre = (String)attributes.get("nombre");

		if (nombre != null) {
			setNombre(nombre);
		}

		String region = (String)attributes.get("region");

		if (region != null) {
			setRegion(region);
		}

		String mail = (String)attributes.get("mail");

		if (mail != null) {
			setMail(mail);
		}
	}

	public long getCoordinadorId() {
		return _coordinadorId;
	}

	public void setCoordinadorId(long coordinadorId) {
		_coordinadorId = coordinadorId;
	}

	public String getNombre() {
		return _nombre;
	}

	public void setNombre(String nombre) {
		_nombre = nombre;
	}

	public String getRegion() {
		return _region;
	}

	public void setRegion(String region) {
		_region = region;
	}

	public String getMail() {
		return _mail;
	}

	public void setMail(String mail) {
		_mail = mail;
	}

	public BaseModel<?> getCoordinadorRemoteModel() {
		return _coordinadorRemoteModel;
	}

	public void setCoordinadorRemoteModel(BaseModel<?> coordinadorRemoteModel) {
		_coordinadorRemoteModel = coordinadorRemoteModel;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			CoordinadorLocalServiceUtil.addCoordinador(this);
		}
		else {
			CoordinadorLocalServiceUtil.updateCoordinador(this);
		}
	}

	@Override
	public Coordinador toEscapedModel() {
		return (Coordinador)Proxy.newProxyInstance(Coordinador.class.getClassLoader(),
			new Class[] { Coordinador.class }, new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		CoordinadorClp clone = new CoordinadorClp();

		clone.setCoordinadorId(getCoordinadorId());
		clone.setNombre(getNombre());
		clone.setRegion(getRegion());
		clone.setMail(getMail());

		return clone;
	}

	public int compareTo(Coordinador coordinador) {
		long primaryKey = coordinador.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		CoordinadorClp coordinador = null;

		try {
			coordinador = (CoordinadorClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = coordinador.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(9);

		sb.append("{coordinadorId=");
		sb.append(getCoordinadorId());
		sb.append(", nombre=");
		sb.append(getNombre());
		sb.append(", region=");
		sb.append(getRegion());
		sb.append(", mail=");
		sb.append(getMail());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(16);

		sb.append("<model><model-name>");
		sb.append("slcu.model.Coordinador");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>coordinadorId</column-name><column-value><![CDATA[");
		sb.append(getCoordinadorId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>nombre</column-name><column-value><![CDATA[");
		sb.append(getNombre());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>region</column-name><column-value><![CDATA[");
		sb.append(getRegion());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>mail</column-name><column-value><![CDATA[");
		sb.append(getMail());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _coordinadorId;
	private String _nombre;
	private String _region;
	private String _mail;
	private BaseModel<?> _coordinadorRemoteModel;
}